/*  Game/Army Editor for yALB - Yet Another List Builder (roster Editor for Wargames/tabletop games).
    Copyright (C) 2008-2012  Daniel Ricardo Castro Alvarado

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

#ifndef STRUCTSWRITER_H
#define STRUCTSWRITER_H

#include "gameStructs.h"
#include "unit.h"
#include <QXmlStreamWriter>

class StructWriter : public QObject
{
    Q_OBJECT
public:    
    StructWriter(QXmlStreamWriter &writer);
    void writeFileInformation(const FileInformation& information);

    void writeUnitCategory(const GameCategory& category, const QString& key);
    void writeUnitCategories(const QVector<KeyPair<GameCategory> > &categories);

    void writeItemCategory(const GameCategory& category, const QString& key);
    void writeItemCategories(const QVector<KeyPair<GameCategory> > &categories);

    void writeOptionCategory(const GameCategory& category, const QString& key);
    void writeOptionCategories(const QVector<KeyPair<GameCategory> > &categories);

    void writeColumn(const Column& col, const QString& key);
    void writeColumns(const QList<KeyPair<Column> > &columns);

    void writeItemProperty(const GameProperty& property, const QString& key);
    void writeItemProperties(const QList<KeyPair<GameProperty> > &properties);

    void writeUnitProperty(const GameProperty& property, const QString& key);
    void writeUnitProperties(const QList<KeyPair<GameProperty> > &properties);

    void writeOptionProperty(const GameProperty& property, const QString& key);
    void writeOptionProperties(const QList<KeyPair<GameProperty> > &properties);

    void writeOption(const UnitOption& option, const QString& key);
    void writeOptions(const QList<KeyPair<UnitOption> > &options);

    void writeItem(const GameItem& item, const QString& key);
    void writeItems(const QVector<KeyPair<GameItem> > &items);

    void writeUnit(const Unit& unit, const QString& key);
    void writeUnits(const QList<KeyPair<Unit> > &units);

    void writeGlobalText(const GlobalText& gText, const QString& key);
    void writeGlobalTexts(const QList<KeyPair<GlobalText> > &texts);

    void writeInheritedUnitCategoryData(const QHash<QString, InheritedCategoryData>& data);
    void writeInheritedItemCategoryData(const QHash<QString, InheritedCategoryData>& data);
    void writeInheritedOptionCategoryData(const QHash<QString, InheritedCategoryData>& data);
    void writeInheritedItemData(const QHash<QString, InheritedItemData>& data);
    void writeInheritedOptionData(const QHash<QString, InheritedOptionData>& data);

private:
    QXmlStreamWriter *writer;

    void writeActions(const Actions& actions);
    void writeProperties(const QHash<QString, QString>& properties);
    void writeCells(const QHash<QString, QString>& cells);
    void writeItemLimits(const QHash<QString, InheritedCategoryData>& limits);
};

#endif // STRUCTSWRITER_H
